package com.moshang.blog.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moshang.blog.entity.UploadInfo;
import com.moshang.blog.mapper.UploadInfoMapper;
import com.moshang.blog.service.UploadInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @program: blog
 * @description: ${description}
 * @author: xieweiwei
 * @create: 2018-09-30 16:46
 **/
@Service("uploadInfoService")
@Transactional(rollbackFor = Exception.class)
public class UploadInfoServiceImpl extends ServiceImpl<UploadInfoMapper, UploadInfo> implements UploadInfoService {
    @Resource
    private UploadInfoMapper uploadInfoMapper;
    @Override
    public UploadInfo getOneInfo() {
        QueryWrapper<UploadInfo> param=new QueryWrapper();
        param.eq("is_activited",0);
        UploadInfo uploadInfo=this.uploadInfoMapper.selectOne(param);
        if (uploadInfo!=null){
            return uploadInfo;
        }
        return null;
    }

    @Override
    public void updateInfo(UploadInfo uploadInfo) {
        updateById(uploadInfo);
    }
}
